<!DOCTYPE html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/view/common/common.jsp"%>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">
    <meta http-equiv="expires" content="0">
    <meta http-equiv="keywords" content="${keywords}">
    <meta http-equiv="description" content="">
    <%@include file="/WEB-INF/view/common/head_css.jsp"%>
    <%@include file="/WEB-INF/view/common/head_css_startbootstrap.jsp"%>
    <%@include file="/WEB-INF/view/common/head_css_upload.jsp"%>
    <%@include file="/WEB-INF/view/common/head_css_fav.jsp"%>
    <%@include file="/WEB-INF/view/common/hf_css_upload.jsp"%>
    <link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0-RC3/css/bootstrap-datepicker.min.css" rel="stylesheet">
    <title>产品管理</title>
</head>
<body>
<div id="wrapper">
    <jsp:include page="/menu.html"></jsp:include>
    <div id="page-wrapper">
        <nav class="navbar navbar-default" role="navigation">
            <div class="container-fluid">
                <div class="collapse navbar-collapse" id="top-navbar-collapse">
                    <form class="navbar-form navbar-left" id="searchForm"
                          role="search" action="<c:url value='/sub/goods/index.html'/>"
                          method="GET">
                        <input type="hidden" name="action" value="list" /> <input
                            type="hidden" name="resourceCode" value="${resourceCode }" />
                        <div class="form-group">
                            <label class="">产品名称</label> <input type="text"
                                                                value="${parameter.entity.name}" name="entity.name" id="name"
                                                                autofocus class="typeahead form-control" placeholder="产品名称">
                            <%--<label class="">积分系数</label> <input type="number"--%>
                            <%--value="${parameter.entity.pointFactor}" name="entity.pointFactor" id="pointFactor"--%>
                            <%--autofocus class="typeahead form-control" placeholder="产品积分系数">--%>
                            <%--<select name="entity.shelf" id="status" class="form-control">--%>
                                <%--<option value="">是否上架</option>--%>
                                <%--&lt;%&ndash;<option value="true" >&ndash;%&gt;--%>
                                    <%--&lt;%&ndash;上架</option>&ndash;%&gt;--%>

                                <%--&lt;%&ndash;<option value="false" >&ndash;%&gt;--%>
                                    <%--&lt;%&ndash;下架</option>&ndash;%&gt;--%>
                                <%--<c:forEach items="${status}" var="s">--%>
                                <%--<option value="${s}" <c:if test="${parameter.entity.status==s}">selected</c:if>>--%>
                                <%--${s.desc}</option>--%>
                                <%--</c:forEach>--%>
                            <%--</select>--%>
                            <%--<c:if test="${users.id == 1 && users.realName == '管理员'}">--%>
                            <%--<label class="">上传者</label> <input type="text"--%>
                                                                <%--value="${parameter.entity.user.realName}" name="entity.user.realName" id="realName"--%>
                                                                <%--autofocus class="typeahead form-control" placeholder="上传者姓名">--%>
                            <%--<label class="">编号</label> <input type="text"--%>
                                                                <%--value="${parameter.entity.user.agentCode}" name="entity.user.agentCode" id="agentCode"--%>
                                                                <%--autofocus class="typeahead form-control" placeholder="上传者编号">--%>
                            <%--</c:if>--%>
                            <button type="submit" class="btn btn-primary" id="search"
                                    name="search">
                                <span class="glyphicon glyphicon-search searchBtn"></span>&nbsp;查询
                            </button>
                        </div>
                    </form>
                    <ul class="nav navbar-nav navbar-right">
                        <li><button type="button"
                                    class="btn btn-primary navbar-btn addBtn">
                        <li class="fa fa-plus-square fa-fw"></li>新增产品
                        </button></li>
                    </ul>
                </div>
            </div>
        </nav>
        <div class="row">
            <div class="col-lg-12 col-md-12">
                <div class="table-responsive">
                    <table
                            class="table table-striped table-bordered table-hover table-condensed">
                        <thead>
                        <tr>
                            <th>选择</th>
                            <th>商品名称</th>
                            <th>规格</th>
                            <th>原价格</th>
                            <th>优惠价格</th>
                            <th>当前库存</th>
                            <th>是否上架</th>
                            <th>上传时间</th>
                            <th>上传者</th>
                            <th>编号</th>
                            <th>状态</th>
                            <th>显示顺序</th>
                            <th>操作</th>
                        </tr>
                        </thead>
                        <tbody id="dataList">
                        <c:forEach items="${subGoods}" var="g">
                                <tr data-row="${g.id}" <c:if test="${g.shelf}"> class="danger"</c:if>>
                                    <td><input type="checkbox" value="${g.id}"></td>
                                    <td>${g.name}</td>
                                    <td>${g.spec}</td>
                                    <td>${g.price}</td>
                                    <td>${g.retailPrice}</td>
                                    <td>${g.stockQuantity}</td>
                                    <td>
                                        <c:if test="${g.shelf == true}"><span style="color: #2ebdbc">上架</span></c:if>
                                        <c:if test="${g.shelf == false}"><span style="color: #bfbc98">下架</span></c:if>
                                    </td>
                                    <td>${g.updateTime}</td>
                                    <td>${g.user.realName}</td>
                                    <td>${g.user.agentCode}</td>
                                    <td>
                                        <c:if test="${g.status == 0}">
                                            <span style="color: #4ec31e">已通过</span>
                                        </c:if>
                                        <c:if test="${g.status == 1}">
                                            <span style="color: #ff0000">未通过</span>
                                        </c:if>
                                        <c:if test="${g.status == 2}">
                                            <span style="color: #3e5eff">审核中</span>
                                        </c:if>
                                    </td>
                                    <td>${g.sequence}</td>
                                    <td>
                                        <c:if test="${g.status == 1 || g.status == 2 }">
                                            <c:if test="${g.user.id == users.id}">
                                            <a class="btn btn-success default editBtn"
                                               href="<c:url value='/sub/goods/edit.html?id=${g.id}' /> ">
                                                <span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>修改</a>
                                            </c:if>
                                        <c:if test="${users.id == 1 && users.realName == '管理员'}">
                                            <a class="btn btn-danger default editBtn"
                                               href="<c:url value='/sub/goods/edit1.html?id=${g.id}' /> ">
                                                <span class="glyphicon glyphicon-wrench" aria-hidden="true"></span>审核</a>
                                        </c:if>
                                        </c:if>
                                        <a class="ajaxLink btn btn-danger default" data-role="delete"
                                           href="<c:url value='/sub/goods/remove.json?id=${g.id}' /> ">
                                            <span class="glyphicon glyphicon-remove" aria-hidden="true"></span>删除</a>
                                    </td>
                                </tr>
                        </c:forEach>
                        </tbody>
                    </table>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <jsp:include page="/WEB-INF/view/common/pager.jsp"></jsp:include>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div class="modal-body" id="messageBody"></div>
            <div class="modal-footer"></div>
        </div>
    </div>
</div>
<div class="modal fade" id="winModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="winModalLabel"></h4>
            </div>
            <div class="modal-body" id="winBody"></div>
            <div class="modal-footer"></div>
        </div>
    </div>
</div>

<!-- <!-- 上传进度 -->
<div class="modal fade" id="uploadModal" tabindex="-2" role="dialog"
     aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-lg" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-label="Close">
                    <span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title text-primary" id="myModalLabel">上传进度</h4>
            </div>
            <div class="modal-body">
                <div class="progress progress-striped active">
                    <div class="progress-bar" id="progressbar" role="progressbar" aria-valuenow="45" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
                        <span class="sr-only">45% Complete</span>
                    </div>
                </div>
                <div class="info" id="info">已上传：<span id="has_upload">0</span>MB  速度：<span id="upload_speed">0</span>KB/s</div>
                <div class="info" id="success_info" style="display: none;"></div>
            </div>
            <div class="modal-footer">
                <div class="form-group">
                    <div class="col-md-12 col-xs-12">
                        <button type="button" class="btn btn-primary btn-block quitBtn"
                                tabIndex="26" id="quitBtn" data-dismiss="modal" name="quitBtn"
                                value="login" tabindex="4" data-loading-text="正在返回......">
                            <span class="glyphicon glyphicon-remove-sign">&nbsp;</span>关闭详情
                        </button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div> -->
<jsp:include page="/WEB-INF/view/common/head.jsp"></jsp:include>
<jsp:include page="/WEB-INF/view/common/startbootstrap.jsp"></jsp:include>
<jsp:include page="/WEB-INF/view/common/script_upload.jsp"></jsp:include>
<jsp:include page="/WEB-INF/view/common/script_common.jsp"></jsp:include>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0-RC3/js/bootstrap-datepicker.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0-RC3/locales/bootstrap-datepicker.zh-CN.min.js"></script>
<script type="text/javascript">
    $(function() {
        $(".addBtn").click(
            function(e) {
                e.preventDefault();
                e.stopPropagation();
                $("#myModal").load(
                    "<c:url value='/sub/goods/edit.html'/>",
                    function(e) {
                        $('#myModal').modal({
                            backdrop : "static"
                        });
                    });
            });
        $(".editBtn").click(function(e){
            e.preventDefault();
            e.stopPropagation();
            $("#myModal").load($(this).attr("href"),function(e) {
                $('#myModal').modal({
                    backdrop : "static"
                });
            });
        });
        $("#dataList a.ajaxLink").click(function(e){
            e.preventDefault();
            e.stopPropagation();
            var method="POST";
            if($(this).attr("data-role")){
                if(!window.confirm("删除后无法恢复数据,是否继续删除?")){
                    return false;
                }
                method="DELETE";
            }
            var url=$(this).attr("href");
            $.ajax({url:url,method:method,complete:function(xhr,ts){
                    if(xhr.status>=200 && xhr.status<300){
                        window.setTimeout(function() {
                            $("#search").click();
                        }, 1500);
                        $("#winBody").empty().html("操作成功");
                        $("#winModal").modal({backdrop:"static",show:true});

                    }else{
                        $("#winBody").empty().html("操作失败").addClass("text-danger");
                        $("#winModal").modal({backdrop:"static",show:true});
                    }
                }});
        });
        $("tbody tr[data-row]").each(function(index,row){
            $(row).click(function(event){
                if(event.target.nodeName!="INPUT"){
                    rowSelect($(this));
                }
                switchCss($(this));
            });
            $(row).bind("contextmenu",function(){
                return false;
            });
        });
    });
</script>
</body>
</html>